package dome1Exception;

public class ExceptionDome3 {
    public static void main(String[] args) {
        //认识自定义异常，并设计编译时异常
        //test1(19);出现问题直接编译时拦截
        try {
            test1(19);
            System.out.println("代码运行成功");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    public static void test1(int age) throws Exception{
        if(age<=18) {
            throw new AgeIlegalException("年龄不合法");
        }
        else {
            System.out.println("年龄合法");
        }



    }
}
